package com.huazai.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @author EZTTU
 */
public class DoorInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        HttpSession session = request.getSession();


        String uri = request.getRequestURI();
        //其实就是放行所有的login这些东西。
        if (uri.contains("ogin") ||
                uri.contains("ignup") ||
                uri.contains("welcome") ||
                uri.contains("active") ||
                uri.contains("static") ||
                session.getAttribute("userMessage") != null) {
            return true;
        }

        response.sendRedirect(request.getContextPath() + "/door/welcome");
        return false;
    }
}
